
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 05/07/2013 23:07:47
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class InnoApplication
    /// </summary>
    [Serializable]
    public partial class InnoApplication : _DomainLayer_Base
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual System.Guid Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets FK_Language.
        /// </summary>
        /// <value>The FK_Language.</value>
        public virtual int FK_Language
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Name.
        /// </summary>
        /// <value>The Name.</value>
        public virtual string Name
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Description.
        /// </summary>
        /// <value>The Description.</value>
        public virtual string Description
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets DenyRobotIndexing.
        /// </summary>
        /// <value>The DenyRobotIndexing.</value>
        public virtual bool DenyRobotIndexing
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion
        #region Navigation Properties
    
        /// <summary>
        /// Link InnoApplication to all InnoAppUser
        /// </summary>
        public virtual ICollection<InnoAppUser> InnoAppUser
        {
            get
            {
                if (_innoAppUser == null)
                {
                    var newCollection = new FixupCollection<InnoAppUser>();
                    newCollection.CollectionChanged += FixupInnoAppUser;
                    _innoAppUser = newCollection;
                }
                return _innoAppUser;
            }
            set
            {
                if (!ReferenceEquals(_innoAppUser, value))
                {
                    var previousValue = _innoAppUser as FixupCollection<InnoAppUser>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupInnoAppUser;
                    }
                    _innoAppUser = value;
                    var newValue = value as FixupCollection<InnoAppUser>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupInnoAppUser;
                    }
                }
            }
        }
        private ICollection<InnoAppUser> _innoAppUser;
        public virtual InnoRole InnoRole
        {
            get { return _innoRole; }
            set
            {
                if (!ReferenceEquals(_innoRole, value))
                {
                    var previousValue = _innoRole;
                    _innoRole = value;
                    FixupInnoRole(previousValue);
                }
            }
        }
        private InnoRole _innoRole;
    
        /// <summary>
        /// Link InnoApplication to all LayoutMenu
        /// </summary>
        public virtual ICollection<LayoutMenu> LayoutMenu
        {
            get
            {
                if (_layoutMenu == null)
                {
                    var newCollection = new FixupCollection<LayoutMenu>();
                    newCollection.CollectionChanged += FixupLayoutMenu;
                    _layoutMenu = newCollection;
                }
                return _layoutMenu;
            }
            set
            {
                if (!ReferenceEquals(_layoutMenu, value))
                {
                    var previousValue = _layoutMenu as FixupCollection<LayoutMenu>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupLayoutMenu;
                    }
                    _layoutMenu = value;
                    var newValue = value as FixupCollection<LayoutMenu>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupLayoutMenu;
                    }
                }
            }
        }
        private ICollection<LayoutMenu> _layoutMenu;

        #endregion
        #region Association Fixup
    
        private void FixupInnoRole(InnoRole previousValue)
        {
            if (previousValue != null && ReferenceEquals(previousValue.InnoApplication, this))
            {
                previousValue.InnoApplication = null;
            }
    
            if (InnoRole != null)
            {
                InnoRole.InnoApplication = this;
            }
        }
    
        private void FixupInnoAppUser(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (InnoAppUser item in e.NewItems)
                {
                    item.InnoApplication = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (InnoAppUser item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoApplication, this))
                    {
                        item.InnoApplication = null;
                    }
                }
            }
        }
    
        private void FixupLayoutMenu(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (LayoutMenu item in e.NewItems)
                {
                    item.InnoApplication = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (LayoutMenu item in e.OldItems)
                {
                    if (ReferenceEquals(item.InnoApplication, this))
                    {
                        item.InnoApplication = null;
                    }
                }
            }
        }

        #endregion
    }
}
